home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / pcscheme / geneva / pcscheme.exe / DOC / MANUAL.ASC < prev    next >
Encoding:
Text File  |  1994-01-03  |  69.3 KB  |  2,373 lines

  1.  
  2.  
  3.  
  4.        PC Scheme-Geneva:
  5.  
  6.  
  7.       User's documentation
  8.  
  9. Larry Bartholdi       Marc Vuilleumier
  10.  
  11.  
  12.  
  13.            December 22, 1993
  14.  
  15.                                     Abstract
  16.  
  17.  
  18.                                          "My English is worse than the garden o*
  19.  *f my uncle"
  20.                                       _Unknown Chinese philosopher, about 4000 *
  21.  *years ago
  22.  
  23.  
  24. This document describes various major extensions to PcScheme by the Geneva Sche*
  25.  *me Team. These
  26. include BGI, a graphics package based on the interface developed by Borland, an*
  27.  *d Mouse support. More
  28. documentation about Ed will be added here as soon as available.
  29.    BGI is distributed by Borland as C and Pascal libraries. Our adaptation to S*
  30.  *cheme preserves the
  31. spirit of Borland's original product.
  32.    Other documentat about PC Scheme/Geneva are: SCHEME.TEX, the release log fil*
  33.  *e. You should
  34. read it, as it contains the most recent informations about PC Scheme/Geneva; RE*
  35.  *FCARD.TEX, our
  36. Quick Reference Card.  It contains all about PC Scheme/Geneva, including defaul*
  37.  *t key sequences for
  38. Edwin and Ed.
  39.    The authors' work is supported by the University of Geneva. They can be reac*
  40.  *hed at their E-Mail
  41. address "schemege@cui.unige.ch". This document was typeset by LaTEX.
  42.  
  43.  
  44. Contents
  45.  
  46.  
  47. I   Ed: a Generic Editor                                                      2
  48.  
  49.  
  50. 1 Keystrokes                                                                   3
  51.    1.1 Basic Editor Commands  : : : : : : : : : : : : : : : : : : : : : : : : :*
  52.  * : : : : : : : : : : : :  3
  53.    1.2 Enhanced Editor Commands  : : : : : : : : : : : : : : : : : : : : : : : *
  54.  *: : : : : : : : : : :  4
  55.    1.3 Scheme Editor Commands  : : : : : : : : : : : : : : : : : : : : : : : : *
  56.  *: : : : : : : : : : : :  4
  57.  
  58.  
  59. 2 Driving an Editor                                                            *
  60.  * 5
  61. II   Mouse Support in PcScheme                                             7
  62.  
  63.  
  64. 3 The interfacing                                                              *
  65.  *  8
  66.  
  67.  
  68. 4 A simple example                                                            12
  69. III   BGI: The Graphics Package                                            18
  70.  
  71.  
  72. 5 User's manual                                                                *
  73.  *19
  74.    5.1 What is BGI?  : : : : : : : : : : : : : : : : : : : : : : : : : : : : : *
  75.  *: : : : : : : : : : : : : : 19
  76.    5.2 What is different in PcScheme's implementation of BGI?  : : : : : : : : *
  77.  *: : : : : : : : : : 19
  78.    5.3 Coordinate systems : : : : : : : : : : : : : : : : : : : : : : : : : : :*
  79.  * : : : : : : : : : : : : : 20
  80.    5.4 And further: : :: : : : : : : : : : : : : : : : : : : : : : : : : : : : *
  81.  *: : : : : : : : : : : : : : 20
  82.    5.5 The PS and SPY drivers : : : : : : : : : : : : : : : : : : : : : : : : :*
  83.  * : : : : : : : : : : : : 22
  84.        5.5.1 How to use SPY  : : : : : : : : : : : : : : : : : : : : : : : : : *
  85.  *: : : : : : : : : : : : 22
  86.        5.5.2 How to use PS  : : : : : : : : : : : : : : : : : : : : : : : : : :*
  87.  * : : : : : : : : : : : : 22
  88.  
  89.  
  90. 6 PcScheme BGI primitives reference                                            *
  91.  * 24
  92.    6.1 The Graphics Control System  : : : : : : : : : : : : : : : : : : : : : :*
  93.  * : : : : : : : : : : : : 24
  94.    6.2 Drawing  : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :*
  95.  * : : : : : : : : : : : : : : 26
  96.    6.3 Filling  : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :*
  97.  * : : : : : : : : : : : : : : : 28
  98.    6.4 Bitmapping  : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : *
  99.  *: : : : : : : : : : : : : : 30
  100.    6.5 Writing text : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :*
  101.  * : : : : : : : : : : : : : : 31
  102.    6.6 Using Color  : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :*
  103.  * : : : : : : : : : : : : : : 32
  104.    6.7 Miscellaneous queries : : : : : : : : : : : : : : : : : : : : : : : : : *
  105.  *: : : : : : : : : : : : : : 35
  106. Index                                                                        35
  107.  
  108.                                         1
  109.  
  110.                                 Part  I
  111.  
  112.  
  113.               Ed:  a  Generic  Editor
  114. Ed is an object-oriented editor toolkit using a subset of Brief's key sequences*
  115.  *; you can drive it
  116. from your programs or simply use it as a text editor. You can easily remap any *
  117.  *key sequence to
  118. any function, or even implement new features. Basically, Ed provides four level*
  119.  *s of editor that you
  120. access through four creators (meta-functions):
  121.  
  122. (make-editor [window] ['EXIT-FREELY])=) a basic editor object
  123. (make-enhanced-editor : :):        =) ditto, with additional features
  124. (make-color-editor : :):           =) ditto, with block highlight
  125. (make-scheme-editor : :):          =) ditto, with scheme-specific rules
  126.  
  127.  
  128. Typical use:
  129. (define ed (make-[: :-:]editor))    ; create a full-screen editor
  130. (ed 'REMAP-KEY 27 '@GOTO-LINE)      ; remap Esc to "go to line"
  131. (ed [filename])                     ; open the editor
  132.  
  133.  
  134. If you want a multi-window editor, you can define two or more editors in differ*
  135.  *ent window ports;
  136. scrapbook and keystroke assignements will be shared by all.
  137.  
  138. This part has been written by Marc Vuilleumier.
  139.  
  140.                                      2
  141.  
  142. Chapter  1
  143.  
  144.  
  145. Keystrokes
  146.  
  147.  
  148.  
  149. 1.1    Basic Editor Commands
  150.  
  151.              __
  152.  Step        |_"|      Jump      PgUp
  153.         ___|   |___           ___           ___
  154.         ___ $l_ |_!_|    Ctrl-|__ |$l  Ctrl-|_!_|
  155.  
  156.              |_#|                PgDn
  157.  
  158.  1      Ctrl-PgUp      Delete
  159.      Home   $l  End    BackSpace   $l  Del
  160.         Ctrl-PgDn
  161.  
  162. Alt-I      toggle i_nsert/overwrite mode
  163. Alt-G      g_o to line
  164. Alt-K      k_ill to end of line
  165. Alt-D      d_elete current line
  166. Ctrl-L     refresh display
  167. F7         record a keystroke sequence
  168. F8         replay a keystroke sequence
  169. F10        execute a command by name
  170.  
  171. Alt-E      e_dit another file
  172. Alt-W      w_rite file to disk
  173. Alt-O      choose new o_utput name
  174. Alt-R      r_ead a file into current
  175. Alt-X      ex_it editor
  176.  
  177.                                         3
  178.  
  179.  
  180. 1.2    Enhanced Editor Commands
  181.  
  182.  
  183. Use a Color Editor if you want block highlight features.
  184.  
  185. Alt-M      m_ark block
  186. Alt-L      l_ine block
  187. Alt-C      c_olumn block
  188. <Keypad -> cut block/line to scrap
  189. <Keypad +> copy block/line to scrap
  190. <Keypad => invert block bounds (swap anchor)
  191. Ins        insert scrap into text
  192. Del        delete block
  193. Alt-W      w_rite block/file to disk
  194.  
  195. Alt-[1 : :3:]drop a bookmark
  196. Alt-J [1 : :3:]j_ump to bookmark
  197. Ctrl-R     r_eplicate a command
  198.  
  199. Ctrl-F5    toggle case sensivity
  200. Alt-S or F5s_earch string
  201. Shift-F5   repeat previous search
  202. Alt-T or F6t_ranslate string
  203. Shift-F6   repeat previous translate
  204.  
  205. 1.3    Scheme Editor Commands
  206.  
  207.  
  208. Autoindent is active and color changes on each parenthesis level.
  209.  
  210. Ctrl-A     enlarge mark around Scheme expression
  211. Ctrl-Z     mark the biggest Scheme expression
  212. Ctrl-F10   evaluate marked expression
  213. Alt-F10    evaluate current file
  214. Tab        complete symbol or reindent line/block
  215. Shift-Tab  prepare to add a comment
  216. Alt-Q <key>use key's basic definition
  217.                                         4
  218.  
  219. Chapter  2
  220.  
  221.  
  222. Driving  an  Editor
  223.  
  224. (ed [message] [arguments])    message defaults to 'OPEN
  225. 'OPEN [filename]              pop-up the editor, handle commands
  226. 'SAFE                         ensure current buffer is saved
  227. 'CLEAR                        clear buffer
  228. 'NAME [new-value] :::::::::::::::::::) name of buffer
  229. 'BUFFER [new-value]:::::::::::::::::) a list of strings
  230. 'POSITION [new-value]:::::::::::::::) cursor position
  231. 'INSERT [new-value]:::::::::::::::::) #F when in overwrite mode
  232. 'TAB [new-value]:::::::::::::::::::::) tab expansion width
  233. 'TABULIZE-MODE [new-value]:::::::::) 'COMPRESS, 'NORMAL or 'EXPAND
  234. 'SEPARATORS [new-value] ::::::::::::) string (used for word move)
  235. 'CASE-SENSIVITY [new-value]::::::::) #F when disabled
  236. 'COLORS [new-value]:::::::::::::::::) associative color list
  237. 'COMMENT-COLUMN [new-value]::::::::) column #
  238. 'INDENT-TOKENS [new-value]:::::::::) list of special tokens
  239. 'INPUT-PORT [new-value] ::::::::::::) port used for input
  240. 'DO-STRING string             feed editor with keystrokes
  241. 'READ-ACTION ::::::::::::::::::::::) an action: the next event
  242. 'HANDLE-ACTION action         process one command
  243. 'REMAP-KEY key function
  244. key is (list* [: : :Ascii2] Ascii1)
  245. function if (list* [(context action) : :]:default-action)
  246. context is ~(ed) -! boolean
  247. action|is|a character, a string, or a symbol:
  248.   | '@LEFT            '@WORD-LEFT        '@HOME              '@RIGHT
  249.   | '@WORD-RIGHT      '@END              '@UP                '@PAGE-UP
  250.   |
  251.   | '@TOP-OF-BUFFER   '@DOWN             '@PAGE-DOWN         '@END-OF-BUFFER
  252.   |
  253.   | '@DEL             '@DELETE-TO-EOL    '@DELETE-LINE       '@BACKSPACE
  254.   | '@TAB             '@ENTER            '@QUOTE
  255.   |
  256.   | '@INSERT-MODE     '@GOTO-LINE        '@REFRESH           '@RECORD
  257.   |
  258.   | '@PLAY            '@EXECUTE          '@LOAD              '@READ-INTO
  259.   | '@WRITE           '@RENAME           '@EXIT
  260.   |
  261.   | '@SEARCH          '@REPEAT-SEARCH    '@CASE-SENSITIVITY  '@TRANSLATE
  262.   |
  263.   | '@REPEAT-TRANSLATE'@REPLICATE        '@BOOKMARK-[1: :3:] '@JUMP-TO-[1: :3:]
  264.   |
  265.   | '@MARK-BLOCK      '@LINE-BLOCK       '@COLUMN-BLOCK      '@CUT-BLOCK
  266.   | '@COPY-BLOCK      '@INSERT-BLOCK     '@CANCEL-BLOCK      '@SWAP-ANCHOR
  267.   |
  268.   | '@MARK-EXPR       '@MARK-DEF         '@SCHEME-PARENTHESIS'@COMPLETION
  269.   |
  270.   | '@INDENT          '@COMMENT          '@EVAL              '@EVAL-BLOCK
  271.   |
  272.   | '@SCHEME-ENTER
  273.  
  274.  
  275.  
  276.                                         5
  277.  
  278.  
  279.  
  280.                                Part  II
  281.  
  282.  
  283.       Mouse  Support  in  PcScheme
  284.  
  285. Microsoft(TM) specified a standard interface to drive the mouse from within app*
  286.  *lications. Prac-
  287. tically all mouse vendors adhered to this interface, so it made sense to access*
  288.  * the mouse though
  289. it from within PcScheme. Unfortunately, the standard was designed for interfaci*
  290.  *ng to assembly
  291. language and thus contains some peculiarities, like event handlers, that have c*
  292.  *arefully to be dealt
  293. with.
  294. The solution proposed is a slight extension of PcScheme's core_the virtual mach*
  295.  *ine. An op-code
  296. has been added to support the int 33h calls, as well as an assembly-language ev*
  297.  *ent handler that
  298. dispatches requests to a Scheme closure. The solution is not perfect in the sen*
  299.  *se event handling
  300. cannot be honored in the middle of a basic instruction (for instance, during a *
  301.  *call to readline).
  302. The slowdown due to Scheme handling of even the most simple events (like record*
  303.  *ing a move),
  304. and the context switching required, may render event handling unpractical on sl*
  305.  *ow processors; the
  306. system has nevertheless successfully been used on a fast 80486 PC.
  307.  
  308. This part has been written by Larry Bartholdi.
  309.  
  310.                                      6
  311.  
  312. Chapter  3
  313.  
  314.  
  315. The  interfacing
  316.  
  317.  
  318. The most important differences between the assembly level interface and the Sch*
  319.  *eme procedures are:
  320.  
  321.    o PcScheme has an Object-Oriented interface
  322.  
  323.    o PcScheme uses symbolic constants abundantly (and list of constants instead*
  324.  * of bit masks)
  325.  
  326.    On the lowest level, all requests are executed through
  327.  
  328.  
  329.  
  330. (%MOUSE ax bx cx dx si di [es:dx])
  331.  
  332. which returns a list: (ax bx cx dx) of the CPU registers after the call has bee*
  333.  *n effected. Fortunately you
  334. will never have to call this function directly; but this is how PcScheme's inte*
  335.  *rface works.
  336.    The high-level interface (in MOUSE.FSL) works with a single "mouse" object,
  337.  
  338.  
  339.  
  340. (MOUSE message [parameters])                                                   *
  341.  *   -
  342.  
  343. that translates the message to (%mouse) calls. The messages mouse recognises ar*
  344.  *e:
  345.  
  346.  
  347. ___Message_Args_)_Result____Comments___________________________________________*
  348.  *___
  349.  
  350.                            |
  351.                            |
  352.  'RESET                    |This message should be the first sent when dealing *
  353.  *with the mouse.
  354.                 ) #-buttons||It returns -1 if no mouse is avaliable.
  355.  'SHOW                     |Increments the mouse's visibility count. The count *
  356.  *initially is -1,
  357.                            |can be incremented or decremented, but can never be*
  358.  *come positive
  359.                            |
  360.                            |(calls to 'SHOW are without effect if the count is *
  361.  *  0). The pointer
  362.                            |
  363.                            |is visible only when the count is = 0.
  364.  'HIDE                     |Decrements the mouse's visiblity count.
  365.  'INQ                      |buttons-down is a list containing any of 'LEFT, 'RI*
  366.  *GHT and CENTER.
  367.          ) (buttons-down x y)||The x- and y-positions are thought in 640 x 200 *
  368.  *units, although
  369.                            |they can be redefined to any scaling.  They are alw*
  370.  *ays in linear
  371.                            |
  372.                            |correspondence with the "Mickeys".
  373.  
  374.  
  375.  
  376.                                         7
  377.  
  378.  
  379. ___Message_Args_)_Result____Comments___________________________________________*
  380.  *___
  381.  
  382.                            |
  383.                            |
  384.  'MOVE x y                 |Moves the pointer to an absolute location. As alway*
  385.  *s, (0; 0) is the
  386.                            |
  387.                            |upper left corner. The values are clipped to the li*
  388.  *miting rectangle.
  389.  'PRESS button             |There is an additional field compared to 'INQ: the *
  390.  *number of times
  391.     ) (buttons-down count x|y)|the button has been pressed.  All other values r*
  392.  *efer to the mouse
  393.                            |state when the last "press" occured. The count is r*
  394.  *eset to 0 after
  395.                            |
  396.                            |this call.
  397.                            |
  398.                            |button is a symbol.
  399.  'RELEASE button           |Just like 'PRESS, except it returns the release cou*
  400.  *nt.
  401.     ) (buttons-down count x|y)|
  402.  'LIMITS 'HORIZONTAL x0 x1 ||Sets the mouse's horizontal viewport. It will not *
  403.  *be able to move
  404.                            |out of that area. If it is outside at the moment of*
  405.  * the call, it will be
  406.                            |
  407.                            |projected to the border.
  408.  'LIMITS 'VERTICAL y0 y1   |Sets the mouse's vertical viewport.
  409.  'LIMITS 'BOTH x0 x1 y0 y1 |Sets the mouse's viewport.
  410.  'SHAPE shape              ||Sets the graphics pointer.  shape is a list:  (x-h*
  411.  *ot-spot y-hot-spot
  412.                            |and-mask xor-mask), where the masks are lists of 16*
  413.  * integers. This
  414.                            |
  415.                            |function does not affect the text-mode pointer.
  416.  'CURSOR name              ||Returns a predefined pointer for 'SHAPE. Two sourc*
  417.  *es were used
  418.                    ) cursor|to grab bitmapped pointers:  the X Windows shared l*
  419.  *ibrary (in
  420.                            |
  421.                            |openwin/share/lib/include/bitmaps), and an MsDos pa*
  422.  *ckage
  423.                            |called "Precise Point". Both sources were used with*
  424.  *out permission.
  425.                            |
  426.                            |name is a symbol,  and can have values 'CENTER, 'KE*
  427.  *YBOARD,
  428.                            |'LEFT, 'RIGHT, 'STAR6, 'TARGET (X Windows) and 'ARR*
  429.  *OW, 'BLOCK,
  430.                            |
  431.                            |'CIRCLE, 'EXCLAIM, 'HAND, 'HOURGLAS, 'KITE, 'MESH, *
  432.  *'SMALL,
  433.                            |
  434.                            |'SQUARE,|'STAR4, 'TEXT, 'X (Precise Point).
  435.  'TEXT-TYPE 'SOFTWARE and xor|Sets the text-mode pointer to software, i.e. to m*
  436.  *odification of char-
  437.                            |acters on the screen. and and xor are pairs: (chara*
  438.  *cter . attribute).
  439.                            |
  440.                            |As a simple example,
  441.                            |
  442.                            |
  443.                            |(mouse 'TEXT-TYPE 'SOFTWARE
  444.                            |       (cons (integer->char "#xff) "#xff)
  445.                            |
  446.                            |       (cons (integer->char 0) "#x80))"
  447.                            |
  448.                            |
  449.                            |would make the character under the pointer blink.
  450.  'TEXT-TYPE  'HARDWARE  start|Sets the text-mode pointer to hardware, i.e. uses*
  451.  * the cursor generator
  452.  end                       ||of the graphics adapter. start and end are the sta*
  453.  *rt- and end-rows of
  454.                            |the cursor, usually in range 0-8 or 0-16. Note that*
  455.  * the cursor then
  456.                            |
  457.                            |serves two uses; this mode should be useful especia*
  458.  *lly in an editor,
  459.                            |
  460.                            |if the mouse moves are interpreted as cursor positi*
  461.  *oning.
  462.  'MICKEYS                  ||Returns the mouse's movement in Mickeys since the *
  463.  *previous call
  464.                     ) (x y)|to this function.  A Mickey is the mouse's fundamen*
  465.  *tal unit,
  466.                            |
  467.                            |1=200inch.
  468.  
  469.                                         8
  470.  
  471.  
  472. ___Message_Args_)_Result____Comments___________________________________________*
  473.  *___
  474.  
  475.                            |
  476.                            ||
  477.  'HANDLER handler          ||Installs an event handler.  A handler is a list:  *
  478.  *(events . proce-
  479.                ) old-handler|dure), where events is a list containing any of 'M*
  480.  *OVE, 'LEFT-DOWN,
  481.                            |
  482.                            |'LEFT-UP,  'LEFT  (both  left-button  messages),  '*
  483.  *RIGHT-DOWN,
  484.                            |'RIGHT-UP, 'RIGHT, 'CENTER-DOWN, 'CENTER-UP, 'CENTE*
  485.  *R, 'DOWN,
  486.                            |
  487.                            |'UP, and 'BUTTONS. When one of these events occurs,*
  488.  * procedure will
  489.                            |be called. procedure's arguments are (triggering-ev*
  490.  *ents buttons-down
  491.                            |
  492.                            |x y mickeys-x mickeys-y event-time). Note that trig*
  493.  *gering-events is
  494.                            |
  495.                            |a list, because it may contain more than one event.
  496.                            |An important thing to mention is that normally proc*
  497.  *edure will not
  498.                            |
  499.                            |be reinvoked before it returns. Events that occur d*
  500.  *uring procedure's
  501.                            |execution are lost. In particular, if procedure doe*
  502.  *s not return (in case
  503.                            |
  504.                            |of error, for instance), mouse events remain disabl*
  505.  *ed. They can be
  506.                            |
  507.                            |re-enabled with the next command.
  508.  'ENABLE                   ||Re-enables event handling.  With this, re-entrant *
  509.  *mouse-handlers
  510.                            |can be written!
  511.                            |
  512.                            |In its normal operating mode, mouse stacks up mouse*
  513.  * messages and
  514.                            |dispatches them one at a time, sending the next mes*
  515.  *sage when the
  516.                            |
  517.                            |dispatch of the previous one returned.  If this fun*
  518.  *ction is called,
  519.                            |the message-dispatching system is spawned; in effec*
  520.  *t, calling this
  521.                            |
  522.                            |function from within an event handler may result in*
  523.  * the handler
  524.                            |
  525.                            |being called "re-entrantly".
  526.  'DISABLE                  |This message suppresses re-entrancy by cancelling t*
  527.  *he effect of a
  528.                            |
  529.                            |previous 'ENABLE.
  530.  'PEN-ON                   |Microsoft Manual says "Light-Pen emulation: Enables*
  531.  * light pen
  532.                            |emulation by the mouse driver for IBM BASIC. A "pen*
  533.  * down" con-
  534.                            |
  535.                            |dition is created by simultaneously pressing the le*
  536.  *ft and right mouse
  537.                            |
  538.                            |buttons." I tried darn hard to understand this, wit*
  539.  *hout success.
  540.  'PEN-OFF                  |ditto.
  541.  'MICKEY-RATIO x y         |Sets the number of Mickeys per 8 pixels for horizon*
  542.  *tal and vertical
  543.                            |
  544.                            |mouse motion.
  545.  'EXCLUDE x0 x1 y0 y1      |Defines a rectangle within which the mouse is invis*
  546.  *ible.
  547.  'SPEED-THRESHOLD speed    |Sets the speed limit between simple- and double-spe*
  548.  *ed motion, in
  549.                            |
  550.                            |Mickeys per second.
  551.  'SENSITIVITY [x y speed]  |Reads or sets the Mickey ratio and speed threshold.
  552.                ) (x y speed)||
  553.  'INTERRUPT-RATE rate      ||rate can be 'NONE, 30, 50, 100 or 200, and governs*
  554.  * the tradeoff be-
  555.                            |tween graphic resolution and application performanc*
  556.  *e. It is applica-
  557.                            |
  558.                            |ble only to the InPort mouse (see 'INFORMATION).
  559.  'POINTER-PAGE [page]      |Reads or sets the display page for the mouse pointe*
  560.  *r.
  561.                      ) page||
  562.  'LANGUAGE [language]      ||Reads or sets the language for mouse driver messag*
  563.  *es.  language
  564.                  ) language|can be any of 'ENGLISH, 'FRENCH, 'DUTCH, 'GERMAN, '*
  565.  *SWEDISH,
  566.                            |
  567.                            |'FINNISH, 'SPANISH, 'PORTUGESE or 'ITALIAN.
  568.  
  569.  
  570.  
  571.                                         9
  572.  
  573.  
  574. ___Message_Args_)_Result____Comments___________________________________________*
  575.  *___
  576.  
  577.                            |
  578.                            |
  579.  'INFORMATION              ||Returns information on the mouse driver. version i*
  580.  *s a floating-point
  581.          ) (version type IRQ)|number. type is a symbol: 'BUS, 'SERIAL, 'INPORT,*
  582.  * 'PS/2 or 'HP.
  583.                            |
  584.                            |IRQ is an integer.
  585.                                        10
  586.  
  587. Chapter  4
  588.  
  589.  
  590. A  simple  example
  591.  
  592.  
  593. I include here a simple demo of what can be done with graphics and mouse: a pro*
  594.  *gram that draws lines
  595. at random while the pointer (representing two eyes) winks at the user when he p*
  596.  *resses the buttons.
  597.  
  598. ;* EYES.S
  599.  
  600.  
  601. ;************************************************************************
  602.  
  603.  
  604. ;* *
  605.  
  606.  
  607. ;* PC Scheme/Geneva 4.00 Scheme code *
  608.  
  609.  
  610. ;* *
  611.  
  612.  
  613. ;* (c) 1985-1988 by Texas Instruments, Inc. See COPYRIGHT.TXT *
  614.  
  615.  
  616. ;* (c) 1992 by L. Bartholdi & M. Vuilleumier, University of Geneva *
  617.  
  618.  
  619. ;* *
  620.  
  621.  
  622. ;*----------------------------------------------------------------------*
  623.  
  624.  
  625. ;* *
  626.  
  627.  
  628. ;* A Simple Mouse Demo *
  629.  
  630.  
  631. ;* *
  632.  
  633.  
  634. ;*----------------------------------------------------------------------*
  635.  
  636.  
  637. ;* *
  638.  
  639.  
  640. ;* Created by: L. Bartholdi Date: 19930930 *
  641.  
  642.  
  643. ;* Revision history: *
  644.  
  645.  
  646. ;* - 18 Jun 92: Renaissance (Borland Compilers, ...) *
  647.  
  648.  
  649. ;* *
  650.  
  651.  
  652. ;* ``In nomine omnipotentii dei'' *
  653.  
  654.                                        11
  655.  
  656.  
  657. ;************************************************************************
  658.  
  659. ; 0 . . . . . . . . . . . . . . . .
  660.  
  661.  
  662. ; 1 . . . . . . . . . . . . . . . .
  663.  
  664.  
  665. ; 2 . . o o o . . . . . . . . . . .
  666.  
  667.  
  668. ; 3 . o . . . o . . . . . . . . . .
  669.  
  670.  
  671. ; 4 . o . . . o . . . . . . . . . .
  672.  
  673.  
  674. ; 5 o . . . . . o . . . . . . . . .
  675.  
  676.  
  677. ; 6 o . . . . . o . . . . . . . . .
  678.  
  679.  
  680. ; 7 o . . . . . o . . . . . . . . .
  681.  
  682.  
  683. ; 8 o . . . . . o . . . . . . . . .
  684.  
  685.  
  686. ; 9 o . o o o . o . . . . . . . . .
  687.  
  688.  
  689. ;10 o o . . . o o . . . . . . . . .
  690.  
  691.  
  692. ;11 . o . . . o . . . . . . . . . .
  693.  
  694.  
  695. ;12 . o . . . o . . . . . . . . . .
  696.  
  697.  
  698. ;13 . . o o o . . . . . . . . . . .
  699.  
  700.  
  701. ;14 . . . . . . . . . . . . . . . .
  702.  
  703.  
  704. ;15 . . . . . . . . . . . . . . . .
  705.  
  706.  
  707. ;  151413121110 9 8 7 6 5 4 3 2 1 0
  708.  
  709. (define open-eye '(0 0 ( #b0000000011111111
  710.  
  711.  
  712.  #b0000000011110111
  713.  
  714.  
  715.  #b0000000011100011
  716.  
  717.  
  718.  #b0000000011000001
  719.  
  720.  
  721.  #b0000000011000001
  722.  
  723.  
  724.  #b0000000010000000
  725.  
  726.  
  727.  #b0000000010000000
  728.  
  729.  
  730.  #b0000000010000000
  731.  
  732.  
  733.                                        12
  734.  
  735.  
  736.  #b0000000010000000
  737.  
  738.  
  739.  #b0000000010000000
  740.  
  741.  
  742.  #b0000000010000000
  743.  
  744.  
  745.  #b0000000011000001
  746.  
  747.  
  748.  #b0000000011000001
  749.  
  750.  
  751.  #b0000000011100011
  752.  
  753.  
  754.  #b0000000011110111
  755.  
  756.  
  757.  #b0000000011111111 )
  758.  
  759.       ( #b0000000000000000
  760.  
  761.  
  762.  #b0000000000000000
  763.  
  764.  
  765.  #b0000000000011100
  766.  
  767.  
  768.  #b0000000000100010
  769.  
  770.  
  771.  #b0000000000100010
  772.  
  773.  
  774.  #b0000000001000001
  775.  
  776.  
  777.  #b0000000001000001
  778.  
  779.  
  780.  #b0000000001000001
  781.  
  782.  
  783.  #b0000000001000001
  784.  
  785.  
  786.  #b0000000001011101
  787.  
  788.  
  789.  #b0000000001100011
  790.  
  791.  
  792.  #b0000000000100010
  793.  
  794.  
  795.  #b0000000000100010
  796.  
  797.  
  798.  #b0000000000011100
  799.  
  800.  
  801.  #b0000000000000000
  802.  
  803.  
  804.  #b0000000000000000 )
  805.  
  806.  
  807.       ))
  808.  
  809.  
  810. (define closed-eye `(0 0 ,(caddr open-eye)
  811.  
  812.  
  813.         ( #b0000000000000000
  814.  
  815.  
  816.                                        13
  817.  
  818.  
  819.    #b0000000000000000
  820.  
  821.  
  822.    #b0000000000011100
  823.  
  824.  
  825.    #b0000000000100010
  826.  
  827.  
  828.    #b0000000000100010
  829.  
  830.  
  831.    #b0000000001000001
  832.  
  833.  
  834.    #b0000000001000001
  835.  
  836.  
  837.    #b0000000001011101
  838.  
  839.  
  840.    #b0000000001111111
  841.  
  842.  
  843.    #b0000000001110111
  844.  
  845.  
  846.    #b0000000001100011
  847.  
  848.  
  849.    #b0000000000110110
  850.  
  851.  
  852.    #b0000000000111110
  853.  
  854.  
  855.    #b0000000000011100
  856.  
  857.  
  858.    #b0000000000000000
  859.  
  860.  
  861.    #b0000000000000000 )
  862.  
  863.  
  864.       ))
  865.  
  866. (define (right pattern)
  867.  
  868.  
  869.   (map (lambda (x) (* x #x100)) pattern))
  870.  
  871. (define (join p1 p2)
  872.  
  873.  
  874.   (map (lambda (x y) (bitwise-or x y))
  875.  
  876.  
  877.       p1 (right p2)))
  878.  
  879. (define m0 (list 0 0
  880.  
  881.  
  882.  (join (caddr open-eye) (caddr open-eye))
  883.  
  884.  
  885.  (join (cadddr open-eye) (cadddr open-eye))))
  886.  
  887.  
  888. (define m1 (list 0 0
  889.  
  890.  
  891.                                        14
  892.  
  893.  
  894.  (join (caddr open-eye) (caddr closed-eye))
  895.  
  896.  
  897.  (join (cadddr open-eye) (cadddr closed-eye))))
  898.  
  899.  
  900. (define m2 (list 0 0
  901.  
  902.  
  903.  (join (caddr closed-eye) (caddr open-eye))
  904.  
  905.  
  906.  (join (cadddr closed-eye) (cadddr open-eye))))
  907.  
  908.  
  909. (define m3 (list 0 0
  910.  
  911.  
  912.  (join (caddr closed-eye) (caddr closed-eye))
  913.  
  914.  
  915.  (join (cadddr closed-eye) (cadddr closed-eye))))
  916.  
  917. (init-graph)
  918.  
  919.  
  920. (mouse 'RESET)
  921.  
  922.  
  923. (mouse 'SHOW)
  924.  
  925.  
  926. (mouse 'SHAPE m0)
  927.  
  928.  
  929. (mouse 'HANDLER `((LEFT RIGHT) .
  930.  
  931.  
  932.   ,(lambda (event state . rest)
  933.  
  934.  
  935.     (mouse 'SHAPE
  936.  
  937.  
  938.     (cond
  939.  
  940.  
  941.      ((equal? state '()) m0)
  942.  
  943.  
  944.      ((equal? state '(LEFT)) m1)
  945.  
  946.  
  947.      ((equal? state '(RIGHT)) m2)
  948.  
  949.  
  950.      ((equal? state '(LEFT RIGHT)) m3))))))
  951.  
  952.  
  953. (writeln "Press any key to abort...")
  954.  
  955.  
  956. ((rec loop
  957.  
  958.  
  959.    (lambda (count)
  960.  
  961.  
  962.     (when (not (char-ready?))
  963.  
  964.  
  965.       (let ((fade (* 100 (exp (/ (* count count) -40000.0)))))
  966.  
  967.  
  968.  (if (> (random 100) fade)
  969.  
  970.  
  971.     (begin
  972.  
  973.  
  974.                                        15
  975.  
  976.  
  977.       (mouse 'HIDE)
  978.  
  979.  
  980.       (mouse 'SHOW)
  981.  
  982.  
  983.       (set-color 0))
  984.  
  985.  
  986.     (set-color (1+ (random (-1+ (get-max-color)))))))
  987.  
  988.  
  989.       (line (cons (random (car (get-max-xy))) (random (cdr (get-max-xy))))
  990.  
  991.  
  992.     (cons (random (car (get-max-xy))) (random (cdr (get-max-xy)))))
  993.  
  994.  
  995.       (loop (1+ count)))))
  996.  
  997.  
  998.  0)
  999.  
  1000.  
  1001. (read-char)
  1002.  
  1003.  
  1004. (close-graph)
  1005.  
  1006.  
  1007. (mouse 'RESET)
  1008.  
  1009.  
  1010. ae
  1011.  
  1012.                                        16
  1013.  
  1014.                        Part  III
  1015.  
  1016.  
  1017. BGI:  The  Graphics  Package
  1018.  
  1019.  
  1020.  
  1021.                    Written by Marc Vuilleumier
  1022.  
  1023.  
  1024.  
  1025.        Last change October 5, 1993. First draft November 27, 1992
  1026.  
  1027.  
  1028.                              17
  1029.  
  1030. Chapter  5
  1031.  
  1032.  
  1033. User's  manual
  1034.  
  1035.  
  1036.  
  1037. 5.1    What is BGI?
  1038.  
  1039.  
  1040. BGI is a powerful, standard, device-adaptable interface for graphic output. It *
  1041.  *was introduced by Borland
  1042. compilers, and give programmers a complete set of graphic primitives, working o*
  1043.  *n every device for which a
  1044. BGI driver exist. Included with this version of PcScheme, you'll find drivers f*
  1045.  *or Cga, Mcga, Att-400,
  1046. Ega, Vga, Hercules, Ibm-8514, Pc-3270, Hp95lx and true compatibles.
  1047.    You may use any other BGI driver found on public sites or provided by your g*
  1048.  *raphic hardware vendor
  1049. (such as the SVGA.BGI driver for Super-Vga designed for Borland C 3.0 to improv*
  1050.  *e the resolution and
  1051. color capabilities.
  1052.    You may also use the two drivers one of us (lb) has written, that are distri*
  1053.  *buted with PcScheme:
  1054. SPY.BGI and PS.BGI. The former is a debugging aid that prints to the screen all*
  1055.  * the driver requests.
  1056. The latter creates a PostScript document that can then be incorporated in a tex*
  1057.  *t processor or sent to a
  1058. printer. See section 5.5 for more information.
  1059.  
  1060.  
  1061.  
  1062. 5.2    What is different in PcScheme's implementation of BGI?
  1063.  
  1064.  
  1065.    o The name of primitives and constants is "Scheme-like" splitted in words:
  1066.  
  1067.  
  1068.                     Borland C 3.0           PcScheme
  1069.  
  1070.                     initgraph(...)     =)   (init-graph ...)
  1071.                     setcolor(LIGHTBLUE)=)   (set-color 'LIGHT-BLUE)
  1072.  
  1073.  
  1074.    o Since graphic constants are contextual (which is not the case in C), we ha*
  1075.  *ve removed redundancy
  1076.      in symbol names:
  1077.  
  1078.  
  1079.       Borland C 3.0                              PcScheme
  1080.  
  1081.       setlinestyle(DOTTED_LINE, ...)        =)   (set-line-style 'DOTTED ...)
  1082.       settextstyle(GOTHIC_FONT, HORIZ_DIR, 4)=)  (set-text-style 'GOTHIC HORIZ *
  1083.  *4)
  1084.  
  1085.  
  1086.    o Some parameters are optional. The following commands, for instance, are al*
  1087.  *l equivalent:
  1088.  
  1089.  
  1090.      (init-graph 'DETECT 0 "")
  1091.      (init-graph 'DETECT 0)
  1092.      (init-graph 'DETECT)
  1093.      (init-graph)
  1094.  
  1095.                                        18
  1096.  
  1097.  
  1098.    o Static structures have been replaced by lists. For instance, a polygon is *
  1099.  *not an integer and an array,
  1100.      but simply a list of points.
  1101.  
  1102.    o The coordinate system can be completely adapted by the user.
  1103.  
  1104.    o Twin-functions returning X and Y values have been joined and produce a poi*
  1105.  *nt (i.e. a pair). This
  1106.      is true for text measurement, too.
  1107.  
  1108.    o Special memory allocation functions have not been included.
  1109.  
  1110.  
  1111.  
  1112. 5.3    Coordinate systems
  1113.  
  1114.  
  1115. Most graphic primitives have to place objects, on the screen for instance, give*
  1116.  *n some coordinates; we call
  1117. a "point" the information necessary to explicit a location on the output device.
  1118.    By default, a point is a pair of whole numbers, the X and Y coordinates, and*
  1119.  * therefore it is highly
  1120. device-dependent: using a Color Graphic Adapter (Cga) mode, for instance, the v*
  1121.  *alid coordinate range
  1122. is '(0 . 0) through '(319 . 199) in 4-color mode, and '(0 . 0) and '(639 . 199)*
  1123.  * in Black&White
  1124. mode. With a Hercules-monochrome adapter, the range becomes '(0 . 0) through '(*
  1125.  *719 . 347), and
  1126. so on; '(0 . 0) is always the upper left corner of the screen, contrary to math*
  1127.  *ematical tradition. Note
  1128. that BGI routines usually clip their parameters to the screen rectangle.
  1129.    Now PcScheme allows you to freely define the coordinate system you'd like to*
  1130.  * use. You only need to
  1131. specify the desired coordinates of the upper left and bottom right corner, no m*
  1132.  *atter which video adapter
  1133. or other device is present. A typical sequence would be:
  1134.  
  1135. (init-graph)                            ; detect and initialize video adapter
  1136. (set-world!  '(-100 . -100) '(100 . 100)) ; set the screen coordinates with ori*
  1137.  *gin centered
  1138. (put-pixel '(0 . 0) 'BLUE)               ; plot a blue pixel at center of screen
  1139.  
  1140.    Note that the X and Y coordinates are now real numbers, so you are allowed t*
  1141.  *o call SET-WORLD! with
  1142. parameters like:
  1143.  
  1144. (set-world!  `((- ,pi) . 1) `(,pi . -1)) ; ideal to plot a sine: : :
  1145.  
  1146.    Of course, if you need to scan every pixel, you can use GET-MAX-XY to obtain*
  1147.  * the actual resolution of
  1148. your screen adapter.
  1149.    If you are urging to try BGI by yourself, skip to part 6, page 24. What foll*
  1150.  *ows is an extension to the
  1151. BGI standard.
  1152.  
  1153.  
  1154.  
  1155. 5.4    And further: : :
  1156.  
  1157.  
  1158. For type checking of point parameters, you are allowed to use the SET-POINT?-! *
  1159.  *primitive to change
  1160. the point type. For instance, the following code would allow points to be a pai*
  1161.  *r of real (this is done
  1162. automatically when you use SET-WORLD!).
  1163.  
  1164. (define (real-point point) ; Type-checking for points
  1165.   (and (pair? point)
  1166.        (number? (car point))
  1167.        (number? (cdr point))))
  1168.  
  1169.  
  1170. (set-point?-! real-point)  ; Use the real-coordinates system
  1171.  
  1172.    Now imagine you want to draw a bar chart using an exponential scale.  Instea*
  1173.  *d of adding a call
  1174. to the LOG function before each call to BGI routine, you can define your own co*
  1175.  *ordinates-conversion
  1176. function.  Call SET-COORDINATES! with three functions as parameters, one extrac*
  1177.  *ting the device's X-
  1178. coordinate from a point, one extracting the Y-coordinate, and the reverse proce*
  1179.  *dure which returns the
  1180. point corresponding to given device coordinates:
  1181.  
  1182.  
  1183.  
  1184.                                        19
  1185.  
  1186.  
  1187. (define (my-x point)                  ; X-coord scaled from 0 to 1
  1188.   (round                             ; Return a whole number
  1189.     (* (car point)                    ; Multiply the given X-coordinate: : :
  1190.        (car (get-max-xy)))))           ; : :b:y the maximum X-coordinate
  1191.  
  1192.  
  1193. (define (my-y point)                  ; Y-coord log: 1 (bottom) to 1000
  1194.   (round                             ; Return a whole number
  1195.     (* (- 1 (log (cdr point) 1000))     ; Log of reversed y-coordinate: : :
  1196.        (cdr (get-max-xy)))))           ; : :t:imes the maximum y-coordinate
  1197.  
  1198.  
  1199. (define (reverse-xy xy)                ; Reverse procedure, used when BGI
  1200.   (let ((max-xy (get-max-xy)))         ; wants to return a coordinate
  1201.     (cons                             ; Return a point (a pair)
  1202.       (/ (car xy) (car max-xy))
  1203.       (expt 1000 (- 1 (/ (cdr xy) (cdr max-xy)))))))
  1204.  
  1205.  
  1206. (set-coordinates! my-x my-y reverse-xy) ; Use the vertical-logarithmic system
  1207.  
  1208.    Don't forget to call SET-POINT?-!, because SET-COORDINATES! won't call it fo*
  1209.  *r you (the example
  1210. above assumes you've already typed in the SET-POINT?-! example).
  1211.    Note that using this coordinate system, the same call to a function such as *
  1212.  *LINE-REL can have
  1213. different results, depending on where the pen is:
  1214.  
  1215. (move-to '(0.5 . 1))
  1216. (line-rel '(0 . 10))   ; length = 1/3 of total height
  1217.  
  1218.  
  1219. (move-to '(0.5 . 100)) ; goes up into log scale: : :
  1220. (line-rel '(0 . 10))   ; length = 1/72 of total height
  1221.  
  1222.    Of course, you don't need to assume that a point is a pair; why not a list o*
  1223.  *f numbers, in a three- or
  1224. four-dimensional space? Just write the functions that extract a projection out *
  1225.  *of a vector, and you're
  1226. done!
  1227.    Do you like Euclid? If you don't, you can also define how to calculate dista*
  1228.  *nces, almost the same way
  1229. you defined the coordinates. SET-DISTANCES! accepts three parameters: the X dis*
  1230.  *tance extractor, the Y
  1231. distance extractor and the unary distance extractor. These three functions rece*
  1232.  *ive the point from which
  1233. the distance is to be calculated and the user-desired distance. X & Y distances*
  1234.  * are used for the following
  1235. functions: MOVE-REL, LINE-REL, ELLIPSE, FILL-ELLIPSE and SECTOR, while the unar*
  1236.  *y distance is used
  1237. by ARC, CIRCLE and PIE-SLICE ("unary" means that the function receives distance*
  1238.  *s as a number and
  1239. returns a number; while X and Y distances receive a fictive point which is the *
  1240.  *displacement between two
  1241. points).
  1242.    All these coordinate-manipulation primitives return the previous version of *
  1243.  *all the procedures they
  1244. change, so you can restore them later. In particular, SET-WORLD! returns all of*
  1245.  * seven procedures, in
  1246. the order POINT?, X, Y, REVERSE-XY, X-DIST, Y-DIST, and UNARY-DIST; and all can*
  1247.  * be restored in
  1248. one single call to RESTORE-WORLD!:
  1249.  
  1250. (let ((old-sys (set-world!  '(0 . 0) '(1 . 1)))) ; change and remember
  1251.   ...
  1252.   (restore-world! old-sys))
  1253.  
  1254.    If you want to restore procedures by yourself, note the following example:
  1255.  
  1256. (let* ((old-sys (set-world!  '(0 . 0) '(1 . 1))) ; change and remember
  1257.  (old-point? (car old-sys))
  1258.  (old-coord (cdr old-sys))
  1259.  
  1260.  
  1261.  
  1262.                                        20
  1263.  
  1264.  
  1265.  (old-dist (cdddr old-coord)))
  1266.   ...
  1267.   (set-point?-!     old-point?)
  1268.   (set-coordinates! (car old-coord) (cadr old-coord) (caddr old-coord))
  1269.   (set-distances!   (car old-dist)  (cadr old-dist)  (caddr old-dist))
  1270.  
  1271.  
  1272.  
  1273.    Always restore procedures in this order, since SET-COORDINATES! modifies the*
  1274.  * distance-functions to
  1275. adapt them to the new given system.
  1276.  
  1277.  
  1278.  
  1279. 5.5    The PS and SPY drivers
  1280.  
  1281.  
  1282. This part has been written by Larry Bartholdi.
  1283.    One one the restrictions of BGI was that it could handle displays, but not p*
  1284.  *rinters. To overcome this
  1285. limitation, some people developed "printer packages" for BGI. Although they der*
  1286.  *ive from a real need, they
  1287. are almost useless in that the force a complete re-write of the high-level code*
  1288.  *, linking with extra libraries,
  1289. etc. By contrast, the solution I propose is a simple "plug-and-play": the drive*
  1290.  *r should be recoginsed by
  1291. any system using BGI that allows user-supplied drivers to be installed (see INS*
  1292.  *TALL-USER-DRIVER). The
  1293. price to pay is, of course, that the driver produces only PostScript output. Th*
  1294.  *is postScript can then be
  1295. send to a laser printer, inserted in a text document, or converted to another f*
  1296.  *ormat or device. See for
  1297. instance GNU's "ghostscript".
  1298.    The drivers are written in C. This makes them very easy to change, while req*
  1299.  *uiring very little extra
  1300. space. An interface to the C code, written in assembly language is provided. Us*
  1301.  *ers are free to write their
  1302. own BGI drivers using this system.
  1303.  
  1304.  
  1305.  
  1306. 5.5.1  How to use SPY
  1307.  
  1308. SPY is really a very simple driver, that was written mostly to debug the C inte*
  1309.  *rfacing (whence the name).
  1310. It has only one mode, 1 color (really two_black and white) and a fictive resolu*
  1311.  *tion of 100 x 100. All it
  1312. does is write the graphics requests it receives to the standard output.
  1313.  
  1314.  
  1315.  
  1316. 5.5.2  How to use PS
  1317.  
  1318. PS basically operates like SPY: it translates graphics requests to text, which *
  1319.  *it then writes to a file (or
  1320. the standard output if none is specified).  The environment variable "PS$" spec*
  1321.  *ifies on which file the
  1322. output should go. Beware that the variable cannot be changed from within PcSche*
  1323.  *me. This is a strange
  1324. behaviour I don't really care to deal with; but it is due to duplication of the*
  1325.  * environment.
  1326.    PS accepts a wide variety of display modes, because the Postscript language *
  1327.  *is by nature pixel-
  1328. independent while BGI is pixel-oriented; and the lines' width, points' size etc*
  1329.  *. are determined by the
  1330. device's resolution. There are 6 normal modes, and 6 encapsulated modes. The fo*
  1331.  *rmer create output
  1332. ready to send to a printer, while the latter are best suited to create images t*
  1333.  *o be inserted in a document.
  1334.    There is an eternal problem with color and display versus hardcopy. The colo*
  1335.  *rs are not changed, but
  1336. the greytones are swapped. This is logical since a screen is black by default, *
  1337.  *while a blank sheet of paper
  1338. is white. The driver accepts the same color requests as a Super-Vga card: 16 co*
  1339.  *lors by default and a
  1340. user-settable 256-entry palette. Here are the first preset 16 colors:
  1341.                                        21
  1342.  
  1343.  
  1344.                      Index  Color         Red   Green  Blue
  1345.  
  1346.                          0  White        100%    100%  100%
  1347.                          1  Dark Blue      0%      0%   50%
  1348.                          2  Dark Green     0%     50%    0%
  1349.                          3  Dark Cyan      0%     50%   50%
  1350.                          4  Dark Red      50%      0%    0%
  1351.                          5  Dark Magenta  50%      0%   50%
  1352.                          6  Dark Brown    50%     50%    0%
  1353.                          7  Dark Grey     50%     50%   50%
  1354.                          8  Light Grey    75%     75%   75%
  1355.                          9  Blue           0%      0%  100%
  1356.                         10  Green          0%    100%    0%
  1357.                         11  Cyan           0%    100%  100%
  1358.                         12  Red          100%      0%    0%
  1359.                         13  Magenta      100%      0%  100%
  1360.                         14  Brown        100%    100%    0%
  1361.                         15  Black          0%      0%    0%
  1362.  
  1363. If your printer has no color capabilities, these values are converted to greyto*
  1364.  *nes by combining linearly
  1365. the RGB percentages.
  1366.  
  1367.  
  1368.                  Mode      Type     Resolution  Page Size [inches]
  1369.  
  1370.                      0  Postscript  100 x 100   7 x 7
  1371.                      1  Postscript  320 x 200   11:2 x 7
  1372.                      2  Postscript  640 x 480   9:333 x 7
  1373.                      3  Postscript  1024 x 768  9:333 x 7
  1374.                      4  Postscript  1024 x 1024 7 x 7
  1375.                      5  Postscript  2048 x 2048 7 x 7
  1376.                      6  Encapsulated100 x 100   7 x 7
  1377.                      7  Encapsulated320 x 200   11:200 x 7
  1378.                      8  Encapsulated640 x 480   9:333 x 7
  1379.                      9  Encapsulated1024 x 768  9:333 x 7
  1380.                     10  Encapsulated1024 x 1024 7 x 7
  1381.                     11  Encapsulated2048 x 2048 7 x 7
  1382.  
  1383.  
  1384. An example of PS can be seen in the Hershey sample code. PS has been used there*
  1385.  * to insert sample
  1386. displays in a TEX document.
  1387.    There are no restrictions nor royalties associated to the use, distibution o*
  1388.  *r modification of PS and
  1389. SPY.
  1390.  
  1391.  
  1392.  
  1393.                                        22
  1394.  
  1395. Chapter  6
  1396.  
  1397.  
  1398. PcScheme  BGI  primitives  reference
  1399.  
  1400.  
  1401. This section is a list of recognized BGI primitives, by category.  In each cate*
  1402.  *gory, they are sorted by
  1403. "logical" order, that is, the simplest is at the beginning and the most seldom *
  1404.  *used or complex at the end.
  1405. Essential procedures are marked with a harpoon (-) in the margin. Optional para*
  1406.  *meters are enclosed
  1407. in square brackets ([ ]).
  1408.    Color, video modes and some other types of parameters for which symbols are *
  1409.  *listed in this list can be
  1410. entered either as symbol or as the corresponding number; numbers exist only for*
  1411.  * BGI compatibility, but
  1412. you should only use symbols, as they are more "human". When a function such as *
  1413.  *GET-TEXT-SETTINGS
  1414. is used, a symbol is returned.  The only exceptions are GET-COLOR which returns*
  1415.  * a number to avoid
  1416. confusion when re-mapping the palette, and GET-GRAPH-MODE because the correspon*
  1417.  *ding symbol depends
  1418. on the currently loaded driver and might be not available when using an user-in*
  1419.  *stalled driver. Equivalence
  1420. tables can be found in the BGI-ENVIRONMENT.
  1421.  
  1422.  
  1423.  
  1424. 6.1    The Graphics Control System
  1425.  
  1426.  
  1427. (INIT-GRAPH [driver [graph-mode [path-for-BGI-files]]])                        *
  1428.  *   -
  1429.  
  1430. Init-graph loads the BGI driver into memory, initialize all to the defaults val*
  1431.  *ues and turn the graphic
  1432. device into graphic mode.  You cannot issue any graphic command prior to callin*
  1433.  *g INIT-GRAPH. In
  1434. addition to these standard operations, PcScheme also reduces the 'CONSOLE windo*
  1435.  *w to the bottom 4
  1436. lines of screen, i.e. calls (SPLIT-SCREEN 4). Use (FULL-SCREEN) to use the whol*
  1437.  *e text screen.
  1438.    Driver can be any symbol returned by INSTALL-USER-DRIVER, or one of the foll*
  1439.  *owing:
  1440.  
  1441.  
  1442. 'DETECT              'EGA                'IBM8514             'VGA
  1443. 'CGA                 'EGA64              'HERCMONO            'PC3270
  1444. 'MCGA                'EGAMONO            'ATT400
  1445.  
  1446.  
  1447.    'DETECT causes auto-detection of graphic hardware. It works only for all the*
  1448.  * original Borland drivers
  1449. except Ibm-8514.
  1450.    The graph-mode range depends of the BGI driver.  It can be obtained using th*
  1451.  *e GET-MAX-MODE
  1452. primitive (see below). You can use the following symbols, or a valid number:
  1453.  
  1454.  
  1455. 'CGA-C0        320 x 200, 4 colors       'CGA-HI        640 x 200, 2 colors
  1456. 'CGA-C1        320 x 200, 4 colors       'MCGA-C0       320 x 200, 4 colors
  1457. 'CGA-C2        320 x 200, 4 colors       'MCGA-C1       320 x 200, 4 colors
  1458. 'CGA-C3        320 x 200, 4 colors       'MCGA-C2       320 x 200, 4 colors
  1459.  
  1460.  
  1461. ________________________________1
  1462.    if 256K on board
  1463.  
  1464.  
  1465.  
  1466.                                        23
  1467.  
  1468.  
  1469. 'MCGA-C3       320 x 200, 4 colors       'EGA-HI        640 x 350, 16 colors, 2*
  1470.  * pages
  1471. 'MCGA-MED      640 x 200, 2 colors       'EGA64-LO      640 x 200, 16 colors
  1472. 'MCGA-HI       640 x 480, 2 colors       'EGA64-HI      640 x 350, 16 colors
  1473.  
  1474. 'ATT400-C0     320 x 200, 4 colors       'EGAMONO-HI     640 x 350, 2 colors, 2*
  1475.  * pages1
  1476. 'ATT400-C1     320 x 200, 4 colors       'VGA-LO        640 x 200, 16 colors, 2*
  1477.  * pages
  1478. 'ATT400-C2     320 x 200, 4 colors       'VGA-MED       640 x 350, 16 colors, 2*
  1479.  * pages
  1480. 'ATT400-C3     320 x 200, 4 colors       'VGA-HI        640 x 480, 16 colors
  1481. 'ATT400-MED     640 x 200, 2 colors      'HERCMONO-HI    720 x 348, 2 colors, 2*
  1482.  * pages
  1483. 'ATT400-HI     640 x 400, 2 colors       'PC3270-HI     720 x 350, 2 colors
  1484.  
  1485. 'EGA-LO        640 x 200, 16 colors, 4 pages'IBM8514-LO     1024 x 768, 256 col*
  1486.  *ors
  1487.                                          'IBM8514-HI     640 x 480, 256 colors
  1488.  
  1489.  
  1490.    'CGA-C<n> are modes with same resolution but different palettes:
  1491.  
  1492.    o Mode 0 allows BACKGROUND, LIGHT-GREEN, LIGHT-RED and YELLOW
  1493.  
  1494.    o Mode 1 allows BACKGROUND, LIGHT-CYAN, LIGHT-MAGENTA and WHITE
  1495.  
  1496.    o Mode 2 allows BACKGROUND, GREEN, RED and BROWN
  1497.  
  1498.    o Mode 3 allows BACKGROUND, CYAN, MAGENTA and LIGHT-GRAY
  1499.  
  1500. This is true for 'MCGA-C<n> and 'ATT400-C<n> too.
  1501.    The default values are:
  1502.  
  1503.             driver          'DETECT
  1504.             mode            Best colors, best resolution
  1505.             path-for-BGI-filesPCS-SYSDIR, the directory containing BOOTSTRP.APP
  1506.  
  1507.  
  1508. (SET-WRITE-MODE wmode)
  1509.  
  1510. This global setting allows you to choose what to do when drawing overwrite a pr*
  1511.  *eviously plotted object.
  1512.  
  1513.    Wmode can be one of the following:                                          *
  1514.  *   -
  1515. 'COPY (this is the default)
  1516. 'XOR
  1517.  
  1518.    This function currently works only for lines, rectangles, polygons and text.*
  1519.  * PUT-IMAGE has his own
  1520. setting, with other possible modes.
  1521.  
  1522.  
  1523.  
  1524. (RESTORE-CRT-MODE)                                                             *
  1525.  *   -
  1526.  
  1527. This brings the display back to the text mode when INIT-GRAPH was used, but doe*
  1528.  *sn't unload BGI
  1529. drivers from memory. It is useful with SET-GRAPH-MODE to toggle between graphic*
  1530.  * and text mode.
  1531.  
  1532.  
  1533.  
  1534. (SET-GRAPH-MODE [mode])                                                        *
  1535.  *   -
  1536.  
  1537. This changes the current video mode to the one given as parameter.  Correct val*
  1538.  *ues are listed un-
  1539. der INIT-GRAPH, or can be obtained by a call to GET-MAX-MODE. SET-GRAPH-MODE ca*
  1540.  *n be used with
  1541. RESTORE-CRT-MODE to toggle between graphics and text.
  1542.    The default value for mode is the previously used graph mode.
  1543.  
  1544.  
  1545.  
  1546. (CLOSE-GRAPH)                                                                  *
  1547.  *   -
  1548.  
  1549. This turns the video adapter back to text mode, and unloads the driver from mem*
  1550.  *ory. You should always
  1551. use CLOSE-GRAPH at the end of your graph programs, or you have risks to load an*
  1552.  *other copy of BGI driver
  1553. into memory each time you start it, which would cause sooner or later a fatal o*
  1554.  *ut-of-memory error.
  1555.  
  1556.  
  1557.  
  1558.                                        24
  1559.  
  1560.  
  1561. (GRAPH-DEFAULTS)
  1562.  
  1563. This resets all graphics settings to their default values:
  1564.  
  1565.    o Sets the viewport to entire screen
  1566.  
  1567.    o Moves the pen to upper left corner
  1568.  
  1569.    o Sets the default colors and palette
  1570.  
  1571.    o Sets all default style, patterns, text fonts and justification
  1572.  
  1573.  
  1574.  
  1575. (DETECT-GRAPH)
  1576.  
  1577. Tries to recognize the video hardware present in the computer, and returns the *
  1578.  *detected adapter with
  1579. the best mode available. See the list of adapters and modes under INIT-GRAPH. T*
  1580.  *he returned driver and
  1581. mode (in a pair) can be used to find out what would be the result of a call to *
  1582.  *(INIT-GRAPH 'DETECT).
  1583. User drivers and 'IBM8514 cannot be auto-detected.
  1584.  
  1585.  
  1586.  
  1587. (GET-MODE-RANGE [driver])
  1588.  
  1589. Returns the range of values acceptable as graphics mode for a given video hardw*
  1590.  *are. If driver is not
  1591. valid, returns '(-1 . -1); otherwise returns a pair made of the smallest and th*
  1592.  *e largest mode.
  1593.    This works with Borland "factory" drivers only. Preferably use GET-MAX-MODE.
  1594.    The default value for driver is the current driver.
  1595.  
  1596.  
  1597.  
  1598. (GET-GRAPH-MODE)
  1599.  
  1600. Returns the current graphic mode number. Can be used with SET-GRAPH-MODE to rem*
  1601.  *ember and restore
  1602. the video mode from a session to the other, but should be used carefully in ord*
  1603.  *er to maintain device-
  1604. independence of programs.
  1605.  
  1606.  
  1607.  
  1608. (INSTALL-USER-DRIVER name)
  1609.  
  1610. Installs the driver whose name is specified as user BGI driver. The HP95LX driv*
  1611.  *er should be used this
  1612. way, since it is not part of the standard BGI drivers. INSTALL-USER-DRIVER esta*
  1613.  *blishes a link between
  1614. the driver and the list of known drivers. It returns a symbol, made of name, wh*
  1615.  *ich can then be used
  1616. when calling INIT-GRAPH. The argument name is a string.
  1617.  
  1618.  
  1619.  
  1620. (INSTALL-USER-FONT name)
  1621.  
  1622. Installs the font whose name is specified as user font, and returns its symboli*
  1623.  *c equivalent in same manner
  1624. as INSTALL-USER-DRIVER.
  1625.  
  1626.  
  1627.  
  1628. 6.2    Drawing
  1629.  
  1630.  
  1631. (LINE start-point end-point)                                                   *
  1632.  *   -
  1633.  
  1634. Draws a line using current color, line-style and write-mode. Start-point and en*
  1635.  *d-point are points for the
  1636. current coordinate system, i.e. pairs by default.
  1637.  
  1638.  
  1639.  
  1640. (RECTANGLE upper-left-point lower-right-point)                                 *
  1641.  *   -
  1642.  
  1643. Draws an empty rectangle using current color, line-style, write-mode.
  1644.                                        25
  1645.  
  1646.  
  1647. (DRAW-POLY list-of-points)                                                     *
  1648.  *   -
  1649.  
  1650. Draws a polygon, i.e. lines from points to points. If you want the polygon to b*
  1651.  *e closed, you need to put
  1652. the first point again at the end of the list.
  1653.  
  1654.  
  1655.  
  1656. (CIRCLE center-point radius)                                                   *
  1657.  *   -
  1658.  
  1659. Draws a circle using current color and thickness (part of line-style).  If your*
  1660.  * circles look oval, use
  1661. SET-ASPECT-RATIO to correct them.
  1662.  
  1663.  
  1664.  
  1665. (ARC center-point start-angle end-angle radius)
  1666.  
  1667. Draws an arc of circle using color and thickness (see CIRCLE). Angles are given*
  1668.  * in degrees, using whole
  1669. numbers. ARC returns the coordinates of the arc as GET-ARC-COORDS would have do*
  1670.  * it.
  1671.  
  1672.  
  1673.  
  1674. (ELLIPSE center-point start-angle end-angle distances)
  1675.  
  1676. Exactly the same as ARC, but distances is a pair of X and Y radius.  To draw a *
  1677.  *whole ellipse, let
  1678. start-angle= 0 and end-angle= 360.
  1679.  
  1680.  
  1681.  
  1682. (GET-ARC-COORDS)
  1683.  
  1684. Returns a list of three points: the center-point of the last arc drawn, the sta*
  1685.  *rting-point and the ending-
  1686. point (i.e. 3 pairs). This command is useful if you want to join lines and arc *
  1687.  *curves.
  1688.  
  1689.  
  1690.  
  1691. (SET-ASPECT-RATIO factor)
  1692.  
  1693. Factor is a pair of integers p and q representing a rational number, p=q, a coe*
  1694.  *fficient by which the radius
  1695. is multiplied to obtain the y-radius when drawing a circle or an arc. Use this *
  1696.  *function either to adjust
  1697. circles when your video adapter makes circles oval, or to draw ellipses of give*
  1698.  *n proportion but of different
  1699. sizes.
  1700.  
  1701.  
  1702.  
  1703. (GET-ASPECT-RATIO)
  1704.  
  1705. Returns the factor as described in SET-ASPECT-RATIO.
  1706.  
  1707.  
  1708.  
  1709. (SET-LINE-STYLE line-style user-pattern thickness)                             *
  1710.  *   -
  1711.  
  1712. Sets the line drawing parameters:  style and width.  If line-style is 'USER-BIT*
  1713.  *, user-pattern is a 16-
  1714. bit integer specifying the pattern used to draw straight lines.  For instance, *
  1715.  *a user-defined pattern of
  1716. #b1110001110001010 would draw "____||____||_ __||".
  1717.    Line-style is one of the following:
  1718.  
  1719.  
  1720. 'SOLID               'CENTER             'USER-BIT
  1721. 'DOTTED              'DASHED
  1722.  
  1723.  
  1724.    Thickness can be any positive integer, and in particular:
  1725.  
  1726. 'NORMAL which is 1
  1727. 'THICK  which is 3
  1728.  
  1729. Other values are not illegal, but do not necessarily produce different results.
  1730.  
  1731.  
  1732.  
  1733.                                        26
  1734.  
  1735.  
  1736. (GET-LINE-SETTINGS)
  1737.  
  1738. Returns the list made of the three settings described in SET-LINE-STYLE.
  1739.  
  1740.  
  1741.  
  1742. (MOVE-TO point)
  1743.  
  1744. Moves the "pen" to the given position, without changing anything on the screen.
  1745.  
  1746.  
  1747.  
  1748. (LINE-TO point)
  1749.  
  1750. Draws a line from the current "pen" position to point, using the current line s*
  1751.  *tyle, color and thickness
  1752.  
  1753.  
  1754.  
  1755. (MOVE-REL distances)
  1756.  
  1757. Same as MOVE-TO, except the move is done relatively to the current pen position.
  1758.  
  1759.  
  1760.  
  1761. (LINE-REL distances)
  1762.  
  1763. You make a soup with LINE-TO and MOVE-REL and you'll get it right.
  1764.  
  1765.  
  1766.  
  1767. 6.3    Filling
  1768.  
  1769.  
  1770. (FLOOD-FILL start-point stop-color)                                            *
  1771.  *   -
  1772.  
  1773. Fills a region of the screen starting from start-point until stop-color is enco*
  1774.  *untered. When used with
  1775. open shapes, the whole screen might get filled.
  1776.    FLOOD-FILL is not yet supported for Ibm-8514 and Hp95lx drivers.  Where poss*
  1777.  *ible, avoid using
  1778. FLOOD-FILL.
  1779.  
  1780.  
  1781.  
  1782. (BAR upper-left-point lower-right-point)                                       *
  1783.  *   -
  1784.  
  1785. Draws a solid 2-dimensional bar without outlet, using the current fill pattern *
  1786.  *and fill color.
  1787.  
  1788.  
  1789.  
  1790. (BAR-3D upper-left-point lower-right-point depth top?)
  1791.  
  1792. Draws a solid 3-dimensional bar with outlets, using the current fill pattern an*
  1793.  *d fill color for the front
  1794. face, and current line width and color for outlet. Depth is the 3rd dimension, *
  1795.  *given in the X-dimension
  1796. coordinate system. Top? is #T if a top should be drawn, and #F if not. #T and #*
  1797.  *F can be replaced by 1
  1798. and 0). This function is very useful for drawing bar charts.
  1799.  
  1800.  
  1801.  
  1802. (FILL-POLY list-of-points)
  1803.  
  1804. Draws a filled polygon using the current fill pattern and color. See DRAW-POLY.
  1805.  
  1806.  
  1807.  
  1808. (FILL-ELLIPSE center-point distances)                                          *
  1809.  *   -
  1810.  
  1811. Draws a filled ellipse using the current fill pattern and color.
  1812.  
  1813.  
  1814.  
  1815. (PIE-SLICE center-point start-angle end-angle radius)
  1816.  
  1817. Fills a slice of pie. Angles are given in degrees. Use SET-ASPECT-RATIO if your*
  1818.  * pie looks sad.
  1819.                                        27
  1820.  
  1821.  
  1822. (SECTOR center-point start-angle end-angle distances)
  1823.  
  1824. Draws a slice of a filled ellipse using current fill pattern and fill color (mo*
  1825.  *st general function).
  1826.  
  1827.  
  1828.  
  1829. (SET-FILL-STYLE fill-style color)                                              *
  1830.  *   -
  1831.  
  1832. Sets the current fill pattern to one of the defined pattern and selects the fil*
  1833.  *l color. Fill-style can be one
  1834. of the following:
  1835.  
  1836.                       'EMPTY      all background color
  1837.                       'SOLID      all fill color
  1838.                       'LINE       continuous _______________
  1839.                       'LTSLASH    light
  1840.                       'SLASH      thick
  1841.                       'LTBKSLASH  light      @@ @ @ @@ @ @
  1842.                       'BKSLASH    thick      @@@_@@_@@@_@@__
  1843.                       'HATCH      hatch     |_______________|||||||||||||
  1844.                       'XHATCH     X-hatch    @@@ @@ @@@ @@
  1845.                       'INTERLEAVE 50% grey
  1846.                       'CLOSE-DOT  20% grey
  1847.                       'WIDE-DOT   10% grey
  1848.                       'USER-FILL
  1849.  
  1850. Don't use (SET-FILL-STYLE 'USER-FILL ...), but use SET-FILL-PATTERN instead, or*
  1851.  * you might get
  1852. unpredictable results.
  1853.    For a table of color constants, see SET-COLOR below.
  1854.  
  1855.  
  1856.  
  1857. (SET-FILL-PATTERN fill-pattern color)                                          *
  1858.  *   -
  1859.  
  1860. This call is similar to SET-FILL-STYLE, except that it sets a user-defined patt*
  1861.  *ern instead of a predefined
  1862. one.  A fill-pattern is an 8x8 matrix used to fill surfaces; at the PcSchemelev*
  1863.  *el, it is a list of 8-bit
  1864. integers, each coding one row. Normally there will be 8 elements in the list bu*
  1865.  *t if you put less, PCS will
  1866. assume you want to repeat periodically the given ones. For example, the chain p*
  1867.  *attern
  1868.  
  1869. (SET-FILL-PATTERN '(#b01000100
  1870.                    #b00111000
  1871.                    #b01000100
  1872.                    #b01000100
  1873.                    #b01000100
  1874.                    #b00111000
  1875.                    #b01000100
  1876.                    #b01000100) 'BLUE)
  1877.  
  1878. will produce the same result as
  1879.  
  1880. (SET-FILL-PATTERN '(#b00111000
  1881.                    #b01000100
  1882.                    #b01000100
  1883.                    #b01000100) 'BLUE)
  1884.  
  1885.  
  1886.  
  1887. (GET-FILL-SETTINGS)
  1888.  
  1889. This returns a pair containing the standard fill style number and the fill colo*
  1890.  *r. If the fill style number is
  1891. 12 ('USER-FILL), you can issue a call to GET-FILL-PATTERN to get the exact patt*
  1892.  *ern.
  1893.  
  1894.  
  1895.  
  1896.                                        28
  1897.  
  1898.  
  1899. (GET-FILL-PATTERN)
  1900.  
  1901. This returns a string containing the fill pattern.
  1902.  
  1903.  
  1904.  
  1905. 6.4    Bitmapping
  1906.  
  1907.  
  1908. (CLEAR-DEVICE)                                                                 *
  1909.  *   -
  1910.  
  1911. Fills the whole screen with the background color and moves the pen to the upper*
  1912.  *-left corner.
  1913.  
  1914.  
  1915.  
  1916. (PUT-PIXEL point color)                                                        *
  1917.  *   -
  1918.  
  1919. Plots a single pixel at coordinates specified by point, using the desired color*
  1920.  * (see SET-COLOR below for
  1921. color names).
  1922.  
  1923.  
  1924.  
  1925. (GET-PIXEL point)                                                              *
  1926.  *   -
  1927.  
  1928. Returns the color number of the selected pixel.
  1929.  
  1930.  
  1931.  
  1932. (GET-IMAGE upper-left-point lower-right-point)                                 *
  1933.  *   -
  1934.  
  1935. Returns an image-string containing all bitmap data for the rectangle enclosed b*
  1936.  *etween the two given
  1937. points. Don't try to look at too big strings of this type, or you might have to*
  1938.  * wait for a long time until
  1939. you reach the end, especially if there is a bell every two chars: : :
  1940.    You should use IMAGE-SIZE to figure out how much memory a bitmap needs, and *
  1941.  *never allocate an
  1942. image of 32Kb or more.
  1943.  
  1944.  
  1945.  
  1946. (PUT-IMAGE new-upper-left-point image-string put-mode)                         *
  1947.  *   -
  1948.  
  1949. Rewrites (very quickly!) the whole image saved in image-string, with the upper *
  1950.  *left corner at new-upper-
  1951. left-point. You can use various displaying methods:
  1952.  
  1953.  
  1954. 'COPY            'XOR            'OR             'AND             'NOT
  1955.  
  1956.  
  1957.    This function can be used to animate a small shape on the screen.
  1958.  
  1959.  
  1960.  
  1961. (IMAGE-SIZE upper-left-point lower-right-point)
  1962.  
  1963. Returns the size in bytes required to store the bitmap enclosed between the two*
  1964.  * given points.
  1965.  
  1966.  
  1967.  
  1968. (SET-VIEWPORT upper-left-point lower-right-point clip?)
  1969.  
  1970. Translates the coordinate system so that the coordinates of screen upper-left c*
  1971.  *orner before a call are the
  1972. same as the coordinates of upper-left-point after the call; moves the pen to th*
  1973.  *is point; if clip? is #T or 1,
  1974. clip all incoming function calls to the rectangle between the two points (i.e. *
  1975.  *no drawing will occur outside
  1976. of this zone).
  1977.    The redefinition of viewport is always relative to the whole screen, using t*
  1978.  *he global (user- or not)
  1979. coordinates system.
  1980.  
  1981.  
  1982.  
  1983. (CLEAR-VIEWPORT)
  1984.  
  1985. Fills the active viewport with the background color and moves the pen to the up*
  1986.  *per left corner of the
  1987. viewport.
  1988.  
  1989.  
  1990.  
  1991.                                        29
  1992.  
  1993.  
  1994. (GET-VIEW-SETTINGS)
  1995.  
  1996. Returns the list of SET-VIEWPORT's three parameters (where clip? is either 1 or*
  1997.  * 0).
  1998.  
  1999.  
  2000.  
  2001. (SET-ACTIVE-PAGE page)
  2002.  
  2003. For graphic adapters which support more than one page (see the table at INIT-GR*
  2004.  *APH), this functions
  2005. allows one to choose on which page the next drawings should have effect.
  2006.    It doesn't have to be the visual page, so one can draw off-screen and then b*
  2007.  *ring the prepared page
  2008. using just one command (see SET-VISUAL-PAGE).
  2009.  
  2010.  
  2011.  
  2012. (SET-VISUAL-PAGE page)
  2013.  
  2014. For graphic adapters which support more than one page this functions allows one*
  2015.  * to choose which page
  2016. is to be displayed on the screen.
  2017.    It doesn't have to be the active page, so one can draw off-screen and then b*
  2018.  *ring the prepared page
  2019. using just one command (see SET-ACTIVE-PAGE).
  2020.  
  2021.  
  2022.  
  2023. 6.5    Writing text
  2024.  
  2025.  
  2026. (OUT-TEXT-XY start-point text-string)                                          *
  2027.  *   -
  2028.  
  2029. Writes text-string starting from start-point according to current justification*
  2030.  * (see SET-TEXT-JUSTIFY) and
  2031. text style (see SET-TEXT-STYLE). The current color and write mode are used.
  2032.  
  2033.  
  2034.  
  2035. (OUT-TEXT text-string)
  2036.  
  2037. Writes text-string starting at the current pen position, according to current j*
  2038.  *ustification, style, color and
  2039. write mode. If the current direction is 'HORIZ and the text justification is 'L*
  2040.  *EFT, the pen is moved to
  2041. the right of the text; otherwise, it is left unchanged.
  2042.  
  2043.  
  2044.  
  2045. (SET-TEXT-STYLE font direction size)                                           *
  2046.  *   -
  2047.  
  2048. Sets text appearance properties. Font can be either a number returned by INSTAL*
  2049.  *L-USER-FONT or one of
  2050. the following, where 'DEFAULT is the only bit-mapped font:
  2051.  
  2052.  
  2053. 'DEFAULT             'SANS-SERIF         'SIMPLEX             'EUROPEAN
  2054. 'TRIPLEX             'GOTHIC             'TRIPLEX-SCR         'BOLD
  2055. 'SMALL               'SCRIPT             'COMPLEX
  2056.  
  2057.  
  2058.    Direction is 'HORIZ or 'VERT.
  2059.    Size is either a number from 1 to 10, or 0 for the default size. The default*
  2060.  * size will produce a size of
  2061. 4, but will also enable user character sizes (see SET-USER-CHAR-SIZE below).
  2062.  
  2063.  
  2064.  
  2065. (SET-TEXT-JUSTIFY horiz-just vert-just)                                        *
  2066.  *   -
  2067.  
  2068. Choose where to align the text. Horiz-just is one of the following:
  2069.  
  2070.                     'LEFT           'CENTER           'RIGHT
  2071.  
  2072. Vert-just is one of the following:
  2073.  
  2074.                     'BOTTOM           'CENTER           'TOP
  2075.  
  2076. For example, 'LEFT means that the starting-point is on the top left edge of the*
  2077.  * text.
  2078.  
  2079.  
  2080.  
  2081.                                        30
  2082.  
  2083.  
  2084. (GET-TEXT-SETTINGS)
  2085.  
  2086. Returns a list of the five text settings: font, direction, size, horizontal and*
  2087.  * vertical justification.
  2088.  
  2089.  
  2090.  
  2091. (SET-USER-CHAR-SIZE x-ratio y-ratio)
  2092.  
  2093. When font-size is set to 0, this allows you to give the font any width and heig*
  2094.  *ht. The font's X and Y
  2095. sizes are multiplied by the x- and y-ratios. Ratios are rational numbers, i.e. *
  2096.  *pairs of integers.
  2097.  
  2098.  
  2099.  
  2100. (TEXT-SIZE text-string)                                                        *
  2101.  *   -
  2102.  
  2103. Returns a pair containing the width and height of text-string using the current*
  2104.  * font. It doesn't care about
  2105. text direction. The height is independent of the character written, i.e. an "I"*
  2106.  * has the same height as an
  2107. "x".
  2108.  
  2109.  
  2110.  
  2111. 6.6    Using Color
  2112.  
  2113.  
  2114. (SET-COLOR color)                                                              *
  2115.  *   -
  2116.  
  2117. Sets the current color for all drawing functions. If you are have 16 or more co*
  2118.  *lors, color can be one of
  2119. the following:
  2120.  
  2121.                         Symbol         Equivalent number
  2122.  
  2123.                         'BLACK                         0
  2124.                         'BLUE                          1
  2125.                         'GREEN                         2
  2126.                         'CYAN                          3
  2127.                         'RED                           4
  2128.                         'MAGENTA                       5
  2129.                         'BROWN                         6
  2130.                         'LIGHT-GRAY                    7
  2131.                         'DARK-GRAY                     8
  2132.                         'LIGHT-BLUE                    9
  2133.                         'LIGHT-GREEN                  10
  2134.                         'LIGHT-CYAN                   11
  2135.                         'LIGHT-RED                    12
  2136.                         'LIGHT-MAGENTA                13
  2137.                         'YELLOW                       14
  2138.                         'WHITE                        15
  2139.  
  2140. If you are using Cga, Mcga or Att-400 four-color modes, you should use instead *
  2141.  *the following constants,
  2142. depending on your palette:
  2143.  
  2144.         0  'BACKGROUND 'CGA-LIGHT-GREEN 'CGA-LIGHT-RED     'CGA-YELLOW
  2145.         1  'BACKGROUND 'CGA-LIGHT-CYAN  'CGA-LIGHT-MAGENTA 'CGA-WHITE
  2146.         2  'BACKGROUND 'CGA-GREEN       'CGA-RED           'CGA-BROWN
  2147.         3  'BACKGROUND 'CGA-CYAN        'CGA-MAGENTA       'CGA-LIGHT-GRAY
  2148.  
  2149. You can change the effect of SET-COLOR using SET-PALETTE. With Cga-style adapte*
  2150.  *rs, only the first color
  2151. (i.e. black, the background color) can be changed (it is best to use SET-BK-COL*
  2152.  *OR).
  2153.    If you totally re-map the palette with a Ega or Vga adapter, use SET-COLOR w*
  2154.  *ith numbers rather
  2155. than with symbols, since it doesn't make programs very clear when (SET-COLOR 'B*
  2156.  *LUE) turns color to
  2157. green for example: : :
  2158.  
  2159.                                        31
  2160.  
  2161.  
  2162. (SET-BK-COLOR color)                                                           *
  2163.  *   -
  2164.  
  2165. Sets the background color to the specified color. Color can be any of the follo*
  2166.  *wing (for Cga-likes too):
  2167.  
  2168.                         Symbol         Equivalent number
  2169.  
  2170.                         'BLACK                         0
  2171.                         'BLUE                          1
  2172.                         'GREEN                         2
  2173.                         'CYAN                          3
  2174.                         'RED                           4
  2175.                         'MAGENTA                       5
  2176.                         'BROWN                         6
  2177.                         'LIGHT-GRAY                    7
  2178.                         'DARK-GRAY                     8
  2179.                         'LIGHT-BLUE                    9
  2180.                         'LIGHT-GREEN                  10
  2181.                         'LIGHT-CYAN                   11
  2182.                         'LIGHT-RED                    12
  2183.                         'LIGHT-MAGENTA                13
  2184.                         'YELLOW                       14
  2185.                         'WHITE                        15
  2186.  
  2187.    On Cga-ish and Ega systems, SET-BK-COLOR only changes the entry 0 of the pal*
  2188.  *ette.
  2189.    If you totally re-map the palette with a Ega or Vga adapter, use SET-BK-COLO*
  2190.  *R with numbers rather
  2191. than symbols.
  2192.  
  2193.  
  2194.  
  2195. (GET-COLOR)
  2196.  
  2197. Returns current color number (not symbol, since a palette change would mix-up e*
  2198.  *verything).
  2199.  
  2200.  
  2201.  
  2202. (GET-BK-COLOR)
  2203.  
  2204. Returns current background color number.
  2205.  
  2206.  
  2207.  
  2208. (GET-MAX-COLOR)                                                                *
  2209.  *   -
  2210.  
  2211. Returns the number of the greatest acceptable color for current video mode (i.e*
  2212.  *. #-of-colors minus 1).
  2213.  
  2214.  
  2215.  
  2216. (SET-PALETTE entry color)
  2217.  
  2218. Re-map the given entry of the palette to the specified color. It is useful for *
  2219.  *Ega and Vga (for Cga, it
  2220. works only with entry 0, i.e. background color). Entry is an integer between 0 *
  2221.  *and (GET-PALETTE-SIZE),
  2222. and color is an integer between 0 and a constant depending on the hardware devi*
  2223.  *ce.  The following
  2224. constants are defined:
  2225.                                        32
  2226.  
  2227.  
  2228.                        Symbol            Equivalent number
  2229.  
  2230.                        'EGA-BLACK         0  (#b000000)
  2231.                        'EGA-BLUE          1  (#b000001)
  2232.                        'EGA-GREEN         2  (#b000010)
  2233.                        'EGA-CYAN          3
  2234.                        'EGA-RED           4  (#b000100)
  2235.                        'EGA-MAGENTA       5
  2236.                        'EGA-LIGHT-GRAY    7
  2237.                        'EGA-BROWN        20
  2238.                        'EGA-DARK-GRAY    56
  2239.                        'EGA-LIGHT-BLUE   57  (#b001001)
  2240.                        'EGA-LIGHT-GREEN  58  (#b010010)
  2241.                        'EGA-LIGHT-CYAN   59
  2242.                        'EGA-LIGHT-RED    60  (#b100100)
  2243.                        'EGA-LIGHT-MAGENTA61
  2244.                        'EGA-YELLOW       62
  2245.                        'EGA-WHITE        63  (#b111111)
  2246.  
  2247.    These are the values of the standard Ega and Vga palette. With these adapter*
  2248.  *s, the following code
  2249. would be equivalent to (SET-ALL-PALETTE (GET-DEFAULT-PALETTE)):
  2250.  
  2251.                (SET-PALETTE 'BLACK 'EGA-BLACK)
  2252.                (SET-PALETTE 'BLUE 'EGA-BLUE)
  2253.                (SET-PALETTE 'RED 'EGA-RED)
  2254.                (SET-PALETTE 'GREEN 'EGA-GREEN)
  2255.                : : :
  2256.                (SET-PALETTE 'WHITE 'EGA-WHITE)
  2257.  
  2258. SET-PALETTE doesn't works with the Ibm-8514. Use SET-RGB-PALETTE instead.
  2259.  
  2260.  
  2261.  
  2262. (SET-RGB-PALETTE entry red green blue)
  2263.  
  2264. This function has the same effect as SET-PALETTE, except that it works only wit*
  2265.  *h the Vga 256k, the
  2266. Ibm-8514, and the Super-Vga adapters. Red, green and blue are the strength of e*
  2267.  *ach color component.
  2268. The 6 most significants bits of the least significant byte are used.
  2269.  
  2270.  
  2271.  
  2272. (SET-ALL-PALETTE color-list)
  2273.  
  2274. Color-list is a list of length (GET-PALETTE-SIZE). This remaps all colors at th*
  2275.  *e same time. There is no
  2276. "entry" parameter as there was with SET-PALETTE, since all colors are re-mapped*
  2277.  * in the normal order.
  2278.  
  2279.  
  2280.  
  2281. (GET-PALETTE)
  2282.  
  2283. Returns a color-list corresponding to current palette.
  2284.  
  2285.  
  2286.  
  2287. (GET-DEFAULT-PALETTE)
  2288.  
  2289. Returns a list with the default palette values.
  2290.  
  2291.  
  2292.  
  2293. (GET-PALETTE-SIZE)
  2294.  
  2295. Returns the number of entries in the palette.
  2296.  
  2297.  
  2298.  
  2299.                                        33
  2300.  
  2301.  
  2302. 6.7    Miscellaneous queries
  2303.  
  2304.  
  2305. (GET-MAX-XY)                                                                   *
  2306.  *   -
  2307.  
  2308. Returns the maximum screen coordinates using pixel dimensions. (1 unit = 1 pixe*
  2309.  *l). It doesn't depend
  2310. of SET-WORLD! settings, so it can be used to determine the actual resolution of*
  2311.  * the current video mode,
  2312. in order to write your own coordinate conversion routine or to scan the screen *
  2313.  *pixel per pixel.
  2314.  
  2315.  
  2316.  
  2317. (GET-XY)
  2318.  
  2319. Returns the current pen location.
  2320.  
  2321.  
  2322.  
  2323. (GET-DRIVER-NAME)                                                              *
  2324.  *   -
  2325.  
  2326. Returns the name of the currently loaded driver, without path and without its "*
  2327.  *.BGI" extension. When
  2328. no driver is loaded, returns "". Can be used to know if a call to INIT-GRAPH is*
  2329.  * necessary or not. A good
  2330. startup code would be:
  2331.  
  2332.                (if (= (GET-DRIVER-NAME) "")
  2333.                    (INIT-GRAPH)
  2334.                    (SET-GRAPH-MODE))
  2335.  
  2336. Thus you can abort your program as often as you want, and restart it without fi*
  2337.  *lling the memory with
  2338. copies of the graphics driver.
  2339.  
  2340.  
  2341.  
  2342. (GET-MODE-NAME mode)
  2343.  
  2344. Returns a string corresponding to the real name of the specified video mode.
  2345.  
  2346.  
  2347.  
  2348. (GET-MAX-MODE)
  2349.  
  2350. Returns the maximum possible value for the video mode for the BGI driver curren*
  2351.  *tly loaded in memory.
  2352. The minimum value is 0.
  2353.  
  2354.  
  2355.  
  2356. (GRAPH-ERROR-MSG error-id)
  2357.  
  2358. Returns the complete text message corresponding to a detected BGI error (actual*
  2359.  *ly used in the debugger;
  2360. you shouldn't need it, except if you want to handle yourself BGI errors).
  2361.  
  2362.  
  2363.  
  2364. (GRAPH-RESULT)
  2365.  
  2366. Returns the error-id corresponding to last BGI call. Use it with GRAPH-ERROR-MS*
  2367.  *G to signal an error
  2368. (already done for you).
  2369.  
  2370.  
  2371.  
  2372.                                        34
  2373.